package com.jzqf.harmonydemo.utils;

import ohos.app.Context;
import ohos.global.resource.NotExistException;
import ohos.global.resource.WrongTypeException;

import java.io.IOException;
import java.util.Arrays;

public class CommonUtil {

    /**
     * Get color method
     *
     * @param context    context resourceID res id
     * @param resourceId res id
     * @return color
     * @since 2020-12-04
     */
    public static int getColor(Context context, int resourceId) {
        try {
            return context.getResourceManager().getElement(resourceId).getColor();
        } catch (IOException | NotExistException | WrongTypeException e) {
            e.printStackTrace();
        }
        return -1;
    }

}
